package com.yt.base.controller.order;

import com.google.common.base.Joiner;
import com.yt.base.controller.core.BaseController;
import com.yt.base.model.AclUser;
import com.yt.base.util.Constants;
import com.yt.base.util.ExcelOpareUtil;
import com.yt.core.MsgBean;
import com.yt.core.dao.PagingBean;
import com.yt.core.dao.filter.DynamicSQLFilterImpl;
import com.yt.core.dao.filter.QueryFilter;
import com.yt.order.api.interfaces.*;
import com.yt.order.api.model.*;
import com.yt.order.api.utils.OrderConstants;
import com.yt.util.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/order/reservation")
public class ReservationController extends BaseController {
	private final static Logger logger = LoggerFactory.getLogger(ReservationController.class);

	@Autowired
	private ReservationService reservationService;
	@Autowired
	private OrderInfoService orderInfoService;
	@Autowired
	private ProductService productService;
	@Autowired
	private InstitutionService institutionService;
	@Autowired
	private GroupOrderService groupOrderService;


	@RequestMapping("/list")
	public ModelAndView list(@RequestParam(value = "orderNo", required = false) String orderNo,
							 @RequestParam(value = "mobile", required = false) String mobile,
							 @RequestParam(value = "cardNumber", required = false) String cardNumber,
							 @RequestParam(value = "endUser", required = false) String endUser,
							 @RequestParam(value = "buyUser", required = false) String buyUser,
							 @RequestParam(value = "startDate", required = false) String startDate,
							 @RequestParam(value = "endDate", required = false) String endDate,
							 @RequestParam(value = "reservationStartDate", required = false) String reservationStartDate,
							 @RequestParam(value = "reservationEndDate", required = false) String reservationEndDate,
							 @RequestParam(value = "groupOrderId", required = false) Long groupOrderId,
							 @RequestParam(value = "isExport", required = false) String isExport,
							 @RequestParam(value = "start", required = false) Integer start,
							 @RequestParam(value = "limit", required = false) Integer limit,
							 HttpServletRequest request,
							 HttpServletResponse response) {
		ModelAndView mav = new ModelAndView("order/reservation/ReservationList");
		try {
			QueryFilter filter = new DynamicSQLFilterImpl();
			int pageNo = start == null ? 1 : start;
			int pageSize = limit == null ? 25 : limit;
			if (StringUtils.isNotEmpty(orderNo)) {
				filter.addFilter("Q_orderNo_S_LK", orderNo.trim());
				mav.addObject("orderNo", orderNo);
			}
			if (StringUtils.isNotEmpty(mobile)) {
				filter.addFilter("Q_mobile_S_LK", mobile.trim());
				mav.addObject("mobile", mobile);
			}
			if (StringUtils.isNotEmpty(cardNumber)) {
				filter.addFilter("Q_cardNumber_S_LK", cardNumber.trim());
				mav.addObject("cardNo", cardNumber);
			}
			if (groupOrderId != null && groupOrderId > 0) {
				filter.addFilter("Q_idGroupOrder_L_EQ", groupOrderId + "");
				mav.addObject("groupOrderId", groupOrderId);
			}

			if (StringUtils.isNotEmpty(buyUser)) {
				filter.addFilter("Q_buyUser_S_LK", buyUser.trim());
				mav.addObject("buyUser", buyUser);
			}
			if (StringUtils.isNotEmpty(endUser)) {
				filter.addFilter("Q_endUser_S_LK", endUser.trim());
				mav.addObject("endUser", endUser);
			}
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			if (StringUtils.isNotEmpty(reservationStartDate)) {
				filter.addFilter("Q_reserveDate_L_GE", sdf.parse(reservationStartDate).getTime() / 1000 + "");
				mav.addObject("reservationStartDate", reservationStartDate);
			}
			if (StringUtils.isNotEmpty(reservationEndDate)) {
				filter.addFilter("Q_reserveDate_L_LE", sdf.parse(reservationEndDate).getTime() / 1000 + "");
				mav.addObject("reservationEndDate", reservationEndDate);
			}
			filter.setSortField("modifyDate desc,id ", true);
			filter.setPagingBean(new PagingBean((pageNo - 1) * pageSize, pageSize));
			List<Reservation> list = reservationService.find(filter);
			if (isExport != null) {
				exportExcel(list, response);
				return null;
			}
			int count = reservationService.count(filter);

			//团体订单
			QueryFilter groupFilter = new DynamicSQLFilterImpl();
			groupFilter.setSortField("id", true);
			groupFilter.setPagingBean(null);
			List<GroupOrder> groupOrderList = groupOrderService.find(groupFilter);
			mav.addObject("groupOrderList", groupOrderList);
			mav.addObject("start", pageNo);
			mav.addObject("limit", pageSize);
			mav.addObject("total", count);
			mav.addObject("list", list);
		} catch (Exception ex) {
			logger.error("出错了，", ex);
		}
		return mav;
	}

	public String reserve() {
//		if (this.orderId != null) {
//			this.orderInfo = orderInfoService.get(this.orderId);
//			this.reservation = reservationService.getReservationByOrderId(this.orderId);
//		} else {
//			this.reservation = reservationService.get(this.id);
//			this.orderInfo = orderInfoService.get(this.reservation.getIdOrder());
//		}
//		this.productId = this.orderInfo.getProduct() != null ? this.orderInfo.getProduct().getId() : null;
//		this.institutionId = this.orderInfo.getInstitution() != null ? this.orderInfo.getInstitution().getId() : null;
//		initInstitutionProduct();
//		if ("1".equals(orderInfo.getBespeaked())) {
//			return "toRereserve";
//		} else {
//			return "toReserve";
//		}
		return null;
	}

	// 提交预约的处理页面
	@RequestMapping("/save")
	@ResponseBody
	public Object save(@RequestParam(value = "id", required = false) Long id,
					   @RequestParam(value = "endUser", required = false) String endUser,
					   @RequestParam(value = "idCard", required = false) String idCard,
					   @RequestParam(value = "sex", required = false) String sex,
					   @RequestParam(value = "age", required = false) Integer age,
					   @RequestParam(value = "phone", required = false) String phone,
					   @RequestParam(value = "mobile", required = false) String mobile,
					   @RequestParam(value = "idInstitution", required = false) Long idInstitution,
					   @RequestParam(value = "idProduct", required = false) Long idProduct,
					   @RequestParam(value = "branch1", required = false) String branch1,
					   @RequestParam(value = "branch", required = false) String branch,
					   @RequestParam(value = "comments", required = false) String comments,
					   @RequestParam(value = "comment", required = false) String comment,
					   @RequestParam(value = "reservationId", required = false) Long reservationId,
					   @RequestParam(value = "reserveDate", required = false) String reserveDate,
					   HttpServletRequest request) {
		MsgBean msg = new MsgBean();
		try {
			AclUser user = (AclUser) request.getSession().getAttribute(Constants.LOGINUSER);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			// 更新订单信息
			OrderInfo order = orderInfoService.get(id);
			order.setMobile(mobile != null?mobile.trim():"");
			order.setPhone(phone != null ? phone.trim():"");
			order.setComment(comment != null ? comment :"");

			//改约
			if (reservationId != null && reservationId > 0) {
				Reservation reservation = reservationService.get(reservationId);
				reservation.setPhone(order.getPhone());
				reservation.setMobile(order.getMobile());
				reservation.setBranch(branch == null ? branch1 : branch);
				if(reservation.getBranch() == null){
					reservation.setBranch("");
				}
				reservation.setReserveDate(sdf.parse(reserveDate).getTime() / 1000);
				reservation.setComments(comments);
				reservationService.update(reservation);
			} else {
				order.setEndUser(endUser.trim());
				order.setSex(sex.trim());
				order.setAge(age);
				order.setMobile(mobile.trim());
				order.setPhone(phone.trim());
				order.setIdCard(idCard.trim());
				order.setBespeaked("1");//已预约

				Reservation reservation = new Reservation();
				reservation.setIdCard(order.getIdCard());
				reservation.setSex(order.getSex());
				reservation.setEndUser(order.getEndUser());
				reservation.setAddress(order.getAddress());
				reservation.setAge(order.getAge());
				reservation.setBasePrice(order.getBasePrice());
				reservation.setBranch(branch1);
				reservation.setBuyUser(order.getBuyUser());
				reservation.setComments(comments.trim());
				reservation.setConfirmed(OrderConstants.ReservationConfirmed.Not.value);
				reservation.setGetReport(order.getReportType());
				reservation.setGroupName(order.getGroupName());

				Institution institution = institutionService.get(idInstitution);
				Product product = productService.get(idProduct);
				reservation.setIdInstitution(institution.getId());
				reservation.setInstitutionName(institution.getName());
				reservation.setIdProduct(idProduct);
				reservation.setProductName(product.getName());
				reservation.setBasePrice(product.getBasePrice());
				reservation.setEmail(order.getEmail());
				reservation.setIdOrder(order.getId());
				reservation.setMobile(order.getMobile());
				reservation.setStatus(OrderConstants.ReservationStatus.New.value);
				reservation.setReserveDate(sdf.parse(reserveDate).getTime() / 1000);
				reservation.setOrderNo(order.getOrderNo());
				reservation.setPhone(order.getPhone());
				reservation.setIdGroupOrder(order.getGroupOrderId());
				reservation.setSalePrice(order.getSalePrice());
				reservation.setModifyDate(System.currentTimeMillis());
				reservation.setLastOperator(user.getName());
				reservation.setNotified("0");
				if(reservation.getBranch() == null){
					reservation.setBranch("");
				}
				reservationService.insert(reservation);
			}

			orderInfoService.update(order);
		} catch (Exception ex) {
			ex.printStackTrace();
			logger.error("预约出错：", ex);
		}


		// this.reservation.setReserveDate(DateUtil.parseDate(reserveDate));
//		if (reservation.getId() == null) {
//			OProductInfo product = productInfoService.get(this.productId);
//			Institution institution = product.getInstitution();
//			// 更新订单信息
//			OrderInfo tmpOrder = orderInfoService.get(orderId);
//			tmpOrder.setTijian(reservation.getTijian());
//			tmpOrder.setAge(reservation.getAge());
//			tmpOrder.setSex(reservation.getSex());
//			tmpOrder.setMobile(reservation.getMobile());
//			tmpOrder.setPhone(reservation.getPhone());
//			tmpOrder.setIdcard(reservation.getIdcard());
//			tmpOrder.setComment(this.orderInfo.getComment());
//			tmpOrder.setProductPrice(product.getPrice());
//			tmpOrder.setBasePrice(product.getBasePrice());
//
//			// 设置已经预约
//			tmpOrder.setBespeaked("1");
//
//			orderInfoService.save(tmpOrder);
//			this.addLog("更新预约状态",tmpOrder.toString(),"OrderInfo");
//			Reservation reserve = new Reservation();
//			reserve.setIdOrder(orderId);
//			reserve.setGroupName(tmpOrder.getGroupName());
//			reserve.setIdGroupOrder(tmpOrder.getGroupOrderId());
//			reserve.setAddContent(tmpOrder.getAddContent());
//			reserve.setAddPrice(tmpOrder.getAddBasePrice());
//			reserve.setAddress(tmpOrder.getAddress());
//			reserve.setAge(reservation.getAge());
//			reserve.setBasePrice(tmpOrder.getBasePrice());
//			reserve.setBuyUser(tmpOrder.getBuyUser());
//			reserve.setComments(reservation.getComments());
//			reserve.setBranch(reservation.getBranch());
//			reserve.setEmail(tmpOrder.getEmail());
//			reserve.setGetReport(tmpOrder.getReportType());
//			reserve.setIdcard(reservation.getIdcard());
//			reserve.setIdInstitution(institution.getId());
//			reserve.setIdOrder(tmpOrder.getId());
//			reserve.setIdProduct(product.getId());
//			reserve.setInstitutionName(institution.getName());
//			reserve.setMobile(reservation.getMobile());
//			reserve.setOrderNo(tmpOrder.getOrderNo());
//			reserve.setProductName(product.getName());
//			reserve.setPhone(reservation.getPhone());
//			reserve.setReserveDate(reservation.getReserveDate());
//			reserve.setSalePrice(tmpOrder.getSalePrice());
//			reserve.setSex(reservation.getSex());
//			reserve.setStatus(OrderConstants.ReservationStatus.New.value);
//			reserve.setConfirmed(OrderConstants.ReservationConfirmed.Not.value);
//			reserve.setTijian(reservation.getTijian());
//			reserve.setModifyDate(currentTime);
//			reserve.setNotified("0");
//			reserve.setLastOperator(ContextUtil.getCurrentUser().getFullname());
//			reservationService.save(reserve);
//			this.addLog("预约体检",reserve.toString(),"Reservation");
//		} else {
//			OrderInfo tmpOrder = orderInfoService.get(orderId);
//			tmpOrder.setMobile(reservation.getMobile());
//			tmpOrder.setPhone(reservation.getPhone());
//			tmpOrder.setComment(orderInfo.getComment());
//			orderInfoService.save(tmpOrder);
//			Reservation tmpReser = reservationService.get(this.reservation.getId());
//			tmpReser.setReserveDate(reservation.getReserveDate());
//			tmpReser.setComments(reservation.getComments());
//			tmpReser.setBranch(reservation.getBranch());
//			tmpReser.setMobile(reservation.getMobile());
//			tmpReser.setPhone(reservation.getPhone());
//			// 只有已经发送并且已经确认的预约，状态才会变为再次发送
//			if (OrderConstants.ReservationStatus.Sent.value.equals(tmpReser.getStatus())
//					&& OrderConstants.ReservationConfirmed.Yes.value.equals(tmpReser.getConfirmed())) {
//				tmpReser.setStatus(OrderConstants.ReservationStatus.ReSent.value);
//			}
//			tmpReser.setLastOperator(ContextUtil.getCurrentUser().getFullname());
//			tmpReser.setModifyDate(currentTime);
//			reservationService.save(tmpReser);
////			this.addLog("预约时更新订单信息",tmpOrder.toString(),"Reservation");
//			this.addLog("预约体检改约",tmpReser.toString(),"Reservation");
//		}
//		this.jsonString = "{success:true}";
		return msg.returnMsg();
	}

	@RequestMapping("/multiDel")
	@ResponseBody
	public Object multiDel(@RequestParam(value = "ids", required = true) String ids) {
		MsgBean msg = new MsgBean();
		String[] idArr = ids.split(",");
		OrderInfo orderInfo = null;
		Reservation reservation = null;
		for (String id : idArr) {
			reservation = reservationService.get(Long.parseLong(id));
			// 只能删除新的预约记录
			if (OrderConstants.ReservationStatus.New.value.equals(reservation.getStatus())) {
				orderInfo = orderInfoService.get(reservation.getIdOrder());
				orderInfo.setBespeaked("0");
				orderInfoService.update(orderInfo);
				//this.addLog("删除预约记录",reservation.toString(),"Reservation");
				reservation.setStatus(OrderConstants.ReservationStatus.Canceled.value);
				reservationService.update(reservation);

//				reservationService.save(reservation);
//				 this.addLog("删除， 把状态置为Negative",
//				 reservation.toString(),"Reservation");
//				 this.addLog("删除预约记录时修改订单预约状态",
//				 "Bespeaked > 0","Reservation");
			}
		}
		return msg.returnMsg();
	}

	/**
	 * 撤销
	 *
	 * @param ids
	 * @return
	 */
	@RequestMapping("/cancel")
	@ResponseBody
	public Object cancel(@RequestParam(value = "ids", required = true) String ids) {
		MsgBean msg = new MsgBean();
		long currentDate = System.currentTimeMillis();
		String[] idArr = ids.split(",");
		OrderInfo orderInfo = null;
		Reservation reservation = null;
		for (String id : idArr) {
			reservation = reservationService.get(Long.parseLong(id));
			reservation.setStatus(OrderConstants.ReservationStatus.Canceled.value);
			reservation.setModifyDate(currentDate);
			reservation.setConfirmed(OrderConstants.ReservationConfirmed.Not.value);
			reservationService.update(reservation);
			//this.addLog("撤销预约",reservation.toString(),"Reservation");

			orderInfo = orderInfoService.get(reservation.getIdOrder());
			orderInfo.setBespeaked("0");
			orderInfoService.update(orderInfo);
			//this.addLog("撤销预约后更新预约状态",orderInfo.toString(),"OrderInfo");
		}
		return msg.returnMsg();
	}

	/**
	 * 发送
	 *
	 * @param ids
	 * @return
	 */
	@RequestMapping("/send")
	@ResponseBody
	public Object send(@RequestParam(value = "ids", required = true) String ids) {
		MsgBean msg = new MsgBean();
		String[] idArr = ids.split(",");
		Reservation reservation = null;
		List<Long> idList = new ArrayList<Long>();

		for (String id : idArr) {
			reservation = reservationService.get(Long.parseLong(id));
			// 只能发送新的预约记录
			if (OrderConstants.ReservationStatus.New.value.equals(reservation.getStatus())) {
				idList.add(reservation.getId());
			}
		}
		if (!idList.isEmpty()) {
			reservationService.updateStatus(Joiner.on(",").join(idList), OrderConstants.ReservationStatus.Sent.value);
		}
		return msg.returnMsg();
	}

	private void initInstitutionProduct() {
//		if (this.orderInfo.getGroupOrderId() != null) {
//			GroupOrder groupOrder = groupOrderService.get(this.orderInfo.getGroupOrderId());
//			if (groupOrder.getProductKeyword() != null && !groupOrder.getProductKeyword().equals("")) {
//				this.institutionList = institutionService.getInstitutionListByProductKeyword(groupOrder.getProductKeyword());
//				if (this.institutionId != null) {
//					this.productList = productInfoService.findProductByKeywordAndInstitutionID(groupOrder.getProductKeyword(), this.institutionId);
//					this.institutionBranchList = institutionBranchService.getByInstituionId(this.institutionId);
//				}
//			} else {
//				this.institutionList = institutionService.getInstitutionListByGroupId(this.orderInfo.getGroupOrderId());
//				if (this.institutionId != null) {
//					this.productList = productInfoService.findProductByGroupAndInstitutionID(this.orderInfo.getGroupOrderId(), this.institutionId);
//					this.institutionBranchList = institutionBranchService.getByInstituionId(this.institutionId);
//				}
//			}
//		}
//
//		if (this.institutionList == null || this.institutionList.size() == 0) {
//			this.institutionList = institutionService.getInstitutionOrderByPinyin();
//		}
//		if (this.institutionId != null) {
//			if(this.productList == null || this.productList.size() == 0){
//				this.productList = productInfoService.findProductByInstitutionID(this.institutionId);
//			}
//			this.institutionBranchList = institutionBranchService.getByInstituionId(this.institutionId);
//		}
//		if (this.productList == null) {
//			this.productList = new ArrayList();
//		}
	}

	public void getSmsContent() {
//		SmsTemplate template = smsTemplateService.get("ReservationSms");
//		Reservation reservation = reservationService.get(this.id);
//		InstitutionBranch branch = null;
//		if(this.branchId != null){
//			branch = institutionBranchService.get(this.branchId);
//		}
//		Institution inst = institutionService.get(this.institutionId);
//		Calendar c = Calendar.getInstance();
//		c.setTime(reservation.getReserveDate());
//		int month = c.get(Calendar.MONTH);
//		int day = c.get(Calendar.DAY_OF_MONTH);
//		String instName = inst.getName();
//		String address = "";
//		if(branch != null){
//			instName += branch.getName();
//			if(branch.getAddress() != null && !"".equals(branch.getAddress())){
//				address = "地址：" + branch.getAddress() + "。";
//			}
//		}else{
//			if(instName.endsWith("体检")){
//				instName = instName.substring(0,instName.lastIndexOf("体检"));
//			}
//			if(inst.getAddress() != null && !"".equals(inst.getAddress())){
//				address = "地址：" + inst.getAddress() + "。";
//			}
//		}
//
//		String sms = MessageFormat.format(template.getSms(), month+1, day, instName, address);
//		printStr("{\"sms\":\"" + sms + "\"}");
	}

	@RequestMapping("/exportSelected")
	@ResponseBody
	public void exportSelected(@RequestParam(value = "ids", required = true) String ids,
							   HttpServletRequest request,
							   HttpServletResponse response) {
		List<Reservation> list = new ArrayList<Reservation>();
		if (ids != null) {
			String id[] = ids.split(";");
			for (String strId : id) {
				list.add(reservationService.get(Long.parseLong(strId)));
			}
		}
		exportExcel(list, response);
	}

	private void exportExcel(List<Reservation> list, HttpServletResponse response) {
		List<String> title = new ArrayList<String>();
		title.add("序号");
		title.add("订单号");
		title.add("团体名称");
		title.add("购买人姓名");
		title.add("检查人姓名");
		title.add("性别");
		title.add("年龄");
		title.add("身份证号");
		title.add("联系方式");
		title.add("套餐");
		title.add("商家名称");
		title.add("分院名称");
		title.add("预约日期");
		title.add("报告领取方式");
		title.add("备注");
		title.add("修改时间");
		title.add("操作员");
		title.add("状态");
		List<List> excelList = new ArrayList<List>();
		List<String> strlist = null;
		int i = 0;
		if (list.size() > 0) {
			for (Reservation ob : list) {
				strlist = new ArrayList<String>();
				i++;
				strlist.add("" + i + "");
				strlist.add("_" + ob.getOrderNo());
				strlist.add(ob.getGroupName() != null ? ob.getGroupName() : "-");
				strlist.add(ob.getBuyUser());
				strlist.add(ob.getEndUser());
				strlist.add(ob.getSex());
				strlist.add((ob.getAge() != null ? ob.getAge().toString() : "-"));
				strlist.add((ob.getIdCard() != null ? ob.getIdCard() : "-"));
				strlist.add(ob.getMobile());
				strlist.add(ob.getProductName());
				strlist.add(ob.getInstitutionName());
				strlist.add(ob.getBranch());
				strlist.add(ob.getReserveDate() != null && ob.getReserveDate() != 0 ? DateUtils.formatDate(new Date(ob.getReserveDate())) : "");
				strlist.add(ob.getGetReport());
				strlist.add(ob.getComments());
				strlist.add(ob.getModifyDate() != null && ob.getModifyDate() != 0 ? DateUtils.formatDate(new Date(ob.getModifyDate())) : "");
				strlist.add(ob.getLastOperator());
				strlist.add(OrderConstants.ReservationStatus.getStatusByValue(ob
						.getStatus())
						+ OrderConstants.ReservationConfirmed.getStatusByValue(ob
						.getConfirmed()));
				excelList.add(strlist);
			}
		}
		response.reset();
		response.setContentType("application/vnd.ms-excel");

		response.setHeader("Content-Disposition", "attachment;Filename=Data(" + System.currentTimeMillis() + ").xls");

		try {
			ExcelOpareUtil.write(response.getOutputStream(), title, excelList);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void smsNotify() {
//		HttpServletRequest request = this.getRequest();
//		Reservation reservation = reservationService.get(id);
//		String sms = request.getParameter("sms");
//		String mobile = request.getParameter("mobile");
//		String result = SmsUtil.sendSMS(mobile, sms);
//		JSONObject json = new JSONObject();
//		if ("0".equals(result)) {
//			reservation.setNotified("1");
//			reservationService.save(reservation);
//			//保存发送历史
//			SmsHistory sh = new SmsHistory();
//			sh.setSendTime(new Date());
//			sh.setRecipients(mobile);
//			sh.setPhoneNumber(mobile);
//			sh.setSmsContent(sms);
//			sh.setStatus((short)1);
//			smsHistoryService.save(sh);
//
//			json.put("success", "true");
//		} else {
//			json.put("success", "false");
//			json.put("error", result);
//		}
////		for (String id : idarray) {
////			reservation = reservationService.get(Long.parseLong(id));
////			date = DateTimeUtil.getFormatTime(reservation.getReserveDate());
////			branch = reservation.getBranch() != null ? reservation.getBranch() : "";
////
////			sms = "";//MessageFormat.format(StaticObject.OORDER_RESERVEREMIND_SMS, reservation.getTijian(), date, branch);
////			result = SmsUtil.sendSMS(reservation.getMobile(), sms);
////			// 保存短信发送记录
////			//saveSMSRecord(reservation.getIdOrder(), reservation.getMobile(), sms, result);
////
////			if ("0".equals(result)) {
////				reservation.setNotified("1");
////				reservationService.save(reservation);
////			} else {
////				json = new JSONObject();
////				json.put("orderno", reservation.getOrderNo());
////				json.put("result", result);
////				ja.add(json);
////			}
////		}
//		printStr(json.toString());
	}
}
